<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * technews 加密函数
 */
if (!function_exists('tn_encrypt')){
	function tn_encrypt($str){
		$ci = &get_instance();
		$ci->load->config('config');
		$encrypt_key = $ci->config->item('tn_encrypt_key');
		return md5(md5($encrypt_key.md5($str))).'-'.$str;
	}
}

if (!function_exists('check_token')){
	function check_token($tokenstr){
		$dynamic_key = mb_substr($tokenstr, mb_stripos($tokenstr, '-')+1);
		return tn_encrypt($dynamic_key)==$tokenstr ? true : false;
	}
}

